package com.example.controller;

import com.example.entity.SpotCheckPlan;
import com.example.service.SpotCheckPlanService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>维保人员抽查计划</p>
 * 说明：维保人员指定抽查计划，下达给指定的人员，进行抽查。
 *  SpotCheckPlanController
 * @author 13169
 * @version 1.6.0
 * @Date 2019/8/24
 *
 */
@RestController
@RequestMapping("api/spotCheckPlan")
public class SpotCheckPlanController {

    @Autowired
    public SpotCheckPlanService spotCheckPlanService;

    /**
     * 查询维保计划的所有数据
     *
     * @param
     * @param
     * @return
     */
    @ApiOperation(value = "查询维保计划的所有数据", notes = "获取列表信息")
    @RequestMapping(value = "findList", method = RequestMethod.POST)
    private Map<String, Object> findList(@RequestBody SpotCheckPlan spotCheckPlan) {
        Map<String, Object> resultMap = spotCheckPlanService.findList(spotCheckPlan);
        return resultMap;
    }

    /**
     * 新增数据
     */
    @ApiOperation(value = "新增维保计划的所有数据", notes = "获取列表信息")
    @RequestMapping(value = "insert", method = RequestMethod.POST)
    private Map<String, Object> insert(@RequestBody SpotCheckPlan spotCheckPlan) {
        Map<String, Object> resultMap = spotCheckPlanService.insert(spotCheckPlan);
        return resultMap;
    }

    /**
     * 批量删除数据
     */
    @ApiOperation(value = "维保计划的批量删除", notes = "删除信息")
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    private Map<String, Object> delete(@RequestBody Map<String, Object> map) {
        List<String> ids = (List<String>) map.get("ids");
        Long userId = Long.valueOf((Integer)map.get("userId")) ;
        Map<String, Object> resultMap = spotCheckPlanService.delete(ids,userId);
        return resultMap;
    }

    /**
     * 修改数据
     */
    @ApiOperation(value = "维保计划的修改", notes = "修改信息")
    @RequestMapping(value = "update", method = RequestMethod.POST)
    private Map<String, Object> update(@RequestBody SpotCheckPlan spotCheckPlan) {
        Map<String, Object> resultMap = spotCheckPlanService.update(spotCheckPlan);
        return resultMap;
    }

}
